using MicroMsg.UI.Page;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class Dialog2BtnWithInputBox : UserControl
	{
		public delegate void dismissWithClickBtn(object sender, int nClickIndex);
		private ModeDialogHelper mDlgHelper;
		private int mNMinInputCount;
		private int mNMaxInputCount = 99999;
		private bool mBIsFirstLoaded = true;
		internal Grid LayoutRoot;
		internal TextBlock txtTitle;
		internal TextBlock txtContent;
		internal TextBox txtIn;
		internal Button btnLeft;
		internal Button btnRight;
		private bool _contentLoaded;
		public event Dialog2BtnWithInputBox.dismissWithClickBtn mBtnClick;
		public event TextChangedEventHandler mTxtInTextChangedHandler;
		private Dialog2BtnWithInputBox(bool isEnableBackKeyPress, string strTitle, string strContent, string strLeftBtnTitle, string strRightBtnTitle, string strInputBoxHint, Dialog2BtnWithInputBox.dismissWithClickBtn clickHandler = null, TextChangedEventHandler textChangedHandler = null, string strTxtInContent = null)
		{
			this.InitializeComponent();
			this.mTxtInTextChangedHandler = textChangedHandler;
			base.add_Loaded(new RoutedEventHandler(this.Dialog2BtnWithInputBox_Loaded));
			this.LayoutRoot.set_Background(R.theme.COMMON_APPBAR_BK_BRUSH);
			if (strTxtInContent != null)
			{
				this.txtIn.set_Text(strTxtInContent);
			}
			this.txtTitle.set_Text(strTitle);
			this.txtContent.set_Text(strContent);
			this.btnLeft.set_Content(strLeftBtnTitle);
			this.btnRight.set_Content(strRightBtnTitle);
			this.mBtnClick = clickHandler;
			this.mDlgHelper = new ModeDialogHelper(this, isEnableBackKeyPress, (SolidColorBrush)Application.get_Current().get_Resources().get_Item("NearOpacityBrush1"), false);
		}
		private void Dialog2BtnWithInputBox_Loaded(object sender, RoutedEventArgs e)
		{
			if (this.mBIsFirstLoaded)
			{
				this.mBIsFirstLoaded = false;
				this.txtIn.Focus();
			}
		}
		public static Dialog2BtnWithInputBox Show(string strTitle, string strContent, string strLeftBtnTitle, string strRightBtnTitle, string strInputBoxHint, Dialog2BtnWithInputBox.dismissWithClickBtn clickHandler = null, TextChangedEventHandler textChangedHandler = null, string strTxtInContent = null)
		{
			Dialog2BtnWithInputBox dialog2BtnWithInputBox = new Dialog2BtnWithInputBox(true, strTitle, strContent, strLeftBtnTitle, strRightBtnTitle, strInputBoxHint, clickHandler, textChangedHandler, strTxtInContent);
			dialog2BtnWithInputBox.mDlgHelper.Show();
			return dialog2BtnWithInputBox;
		}
		private void btnLeft_Click(object sender, RoutedEventArgs e)
		{
			base.Focus();
			if (this.mBtnClick != null)
			{
				this.mBtnClick(this, 0);
			}
			this.mDlgHelper.Hide(null);
		}
		private void btnRight_Click(object sender, RoutedEventArgs e)
		{
			base.Focus();
			if (this.mBtnClick != null)
			{
				this.mBtnClick(this, 1);
			}
			this.mDlgHelper.Hide(null);
		}
		private void txtIn_TextChanged(object sender, TextChangedEventArgs e)
		{
			if (this.mTxtInTextChangedHandler != null)
			{
				this.mTxtInTextChangedHandler.Invoke(this, e);
			}
		}
		private void txtIn_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.get_Key() == 3 && sender == this.txtIn)
			{
				base.Focus();
				e.set_Handled(true);
				this.btnLeft_Click(null, null);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Lbs/UI/Dialog2BtnWithInputBox.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.txtTitle = (TextBlock)base.FindName("txtTitle");
			this.txtContent = (TextBlock)base.FindName("txtContent");
			this.txtIn = (TextBox)base.FindName("txtIn");
			this.btnLeft = (Button)base.FindName("btnLeft");
			this.btnRight = (Button)base.FindName("btnRight");
		}
	}
}
